package com.ddc.study.feature.main.tree.detail;

import com.ddc.study.entity.Article;
import com.ddc.study.entity.MainData;
import com.ddc.study.net.NetworkUtil;

/**
 * Created on 2018/6/6.
 *
 * @author lshun
 * @version 1.0
 */
class TreeDetailPresenter extends TreeDetailContract.IPresenter {
    @Override
    void loadData(final int page, final int cid) {
        if (page < 0) return;

        Runnable runnable = () -> {
            final MainData<Article> data = NetworkUtil.getTreeArticle(page, cid);

            if (!isViewAttached()) return;
            getView().runOnUIThread(() -> {
                if (isViewAttached()) {
                    getView().showData(data);
                }
            });
        };

        mThreadPool.submit(runnable);
    }
}
